<template>
  <div :style="{height:30 + 'px'}" class="rollScreen_container" id="rollScreen_container">
    <div class="nav">
      <div class="nav_left">
        <img src="../../../assets/img/static/imgs/horn.png" alt="">
      </div>
      <div class="nav_right">
        <ul class="nav_ct" :style="transform" v-if="notice.length>0">
          <li v-for="(item,index) in notice" :key="index">{{item}}</li>
          <li>{{notice[0]}}</li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    height: {
      default: 30,
      type: Number
    },
    lineNum: {
      default: 3,
      type: Number
    },
    notice: {
      default: function() {
        return [
         
        ];
      },
      type: Array
    }
  },
  data: function() {
    return {
      num: 0
    };
  },
  computed: {
    transform: function() {
        return "transform:translateY(-" + this.num * this.height + "px);";
    }
  },
  created: function() {
    this.init();
  },
  methods: {
    init() {
      let that = this;
      that.num += 1;
      let timeId = setInterval(function() {
        if (that.num == that.notice.length) { //判断num是否大于或等于notice的长度，让num为0，回到七点
          that.num = 0;
          clearInterval(timeId);  //清除定时器，防止时间停留两个3秒
          that.init();
        } else {
          that.num += 1;
        }
      }, 3000);
    }
  }
};
</script>
 
<style lang="less" scoped>
.rollScreen_container {
  width: 1200px;
  margin: 0 auto;
  margin-bottom: 20px;
  position: relative;
}
 
.nav {
  width: 1200px;
  margin: 0 auto;
  height: 30px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  background: #fff;
//   padding: 0 40px;
  box-sizing: border-box;
  margin-bottom: 20px;
 
  .nav_left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
 
    img {
      width: .16rem;
      height: .16rem;
    }
 
    span {
      font-size: 18px;
      font-weight: 600;
      color: #ec0504;
      margin-left: 20px;
    }
  }
 
  .nav_right {
    width: 80%;
    height: 30px;
    overflow: hidden;
 
    .nav_ct {
      width: 100%;
    //   margin-left: 60px;
 
      li {
        position: relative;
        width: 100%;
        height: 30px;
        line-height: 30px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        font-size: .13rem;
        color: #666;
        padding-left: 10px;
        box-sizing: border-box;
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
 
        // &:before {
        //   content: "";
        //   width: 5px;
        //   height: 5px;
        //   margin-right: 10px;
        //   border-radius: 50%;
        //   background: #000;
        // }
 
        &:hover {
          cursor: pointer;
        }
      }
    }
  }
}
</style>